package com.test.resumeanalysis.ui.talent

import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import com.test.resumeanalysis.R
import com.test.resumeanalysis.common.BaseVBFragment
import com.test.resumeanalysis.data.model.resume.ResumeParse
import com.test.resumeanalysis.databinding.FragmentTalentBinding
import com.test.resumeanalysis.viewModel.PublicViewModel


class TalentFragment :BaseVBFragment<FragmentTalentBinding>(FragmentTalentBinding::inflate){

    lateinit var adapter: TalentAdapter

    private val model:PublicViewModel by activityViewModels()
    private val talentModel: TalentViewModel by viewModels()
    override fun initView() {
        super.initView()


        adapter = TalentAdapter()
        binding.rvTalent.layoutManager = LinearLayoutManager(activity)
        binding.rvTalent.adapter = adapter

        talentModel.getAllResume.observe(this, Observer {
            adapter.data = it as MutableList<ResumeParse>
        })
        adapter.setOnItemClickListener(object : TalentAdapter.OnItemClickListener{
            override fun onItemClick(position: Int) {
                model.selectResume(position)
                findNavController().navigate(R.id.talentInfoFragment)
            }
        })

    }

}